package com.lemonsama.lesson5;

import javax.swing.*;
import java.awt.*;
import java.net.URL;

public class JButtonTest2 extends JFrame {

    public JButtonTest2() {
        Container contentPane = this.getContentPane();
        URL resource = JButtonTest2.class.getResource("1640404870375.png");
        Icon Icon = new ImageIcon(resource);

        JRadioButton jRadioButton1 = new JRadioButton("JRadioButton01");
        JRadioButton jRadioButton2 = new JRadioButton("JRadioButton02");
        JRadioButton jRadioButton3 = new JRadioButton("JRadioButton03");

        //由于单选框只能选择一个，一般分组，一个组中只能选择一个
        ButtonGroup buttonGroup = new ButtonGroup();
        buttonGroup.add(jRadioButton1);
        buttonGroup.add(jRadioButton2);
        buttonGroup.add(jRadioButton3);

        contentPane.add(jRadioButton1, BorderLayout.CENTER);
        contentPane.add(jRadioButton2, BorderLayout.NORTH);
        contentPane.add(jRadioButton3, BorderLayout.SOUTH);

        this.setSize(500, 300);
        this.setVisible(true);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    public static void main(String[] args) {
        new JButtonTest2();
    }
}
